/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * JanelaGraficos.java
 *
 * Created on 21/05/2011, 11:21:38
 */

package GUI;

import java.awt.image.BufferedImage;
import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;

/**
 *
 * @author gilcemar e naliane
 */
public class JanelaGraficos extends javax.swing.JFrame {


    private ControladorDeGeracaoDeGrafico controladorGrafico;

    public void setControladorGrafico(ControladorDeGeracaoDeGrafico controladorGrafico) {
        this.controladorGrafico = controladorGrafico;
        botaoGerarGrafico.addActionListener(controladorGrafico);
        botaoGraficoPadrao.addActionListener(controladorGrafico);
    }

    /** Creates new form JanelaGraficos */
    public JanelaGraficos() {
        initComponents();
        setLocationRelativeTo(null);
        grupoSelecaoDeGrafico.clearSelection();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        grupoSelecaoDeGrafico = new javax.swing.ButtonGroup();
        jPanel1 = new javax.swing.JPanel();
        jRadioButtonMelhoresLocaisDeVendas = new javax.swing.JRadioButton();
        jRadioButtonMelhoresMesesDeVenda = new javax.swing.JRadioButton();
        painelGrafico = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        botaoGerarGrafico = new javax.swing.JButton();
        botaoGraficoPadrao = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();

        setTitle("JanelaGraficosVenda");

        grupoSelecaoDeGrafico.add(jRadioButtonMelhoresLocaisDeVendas);
        jRadioButtonMelhoresLocaisDeVendas.setText("Meses");

        grupoSelecaoDeGrafico.add(jRadioButtonMelhoresMesesDeVenda);
        jRadioButtonMelhoresMesesDeVenda.setText("Localidades");

        javax.swing.GroupLayout painelGraficoLayout = new javax.swing.GroupLayout(painelGrafico);
        painelGrafico.setLayout(painelGraficoLayout);
        painelGraficoLayout.setHorizontalGroup(
            painelGraficoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(painelGraficoLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 640, Short.MAX_VALUE)
                .addContainerGap())
        );
        painelGraficoLayout.setVerticalGroup(
            painelGraficoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 299, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        botaoGerarGrafico.setText("Gerar Gráfico");

        botaoGraficoPadrao.setText("Gráfico Padrão");

        jLabel2.setText("Gráficos de Melhores Meses ou localidades de venda");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(93, 93, 93)
                                .addComponent(jRadioButtonMelhoresLocaisDeVendas, javax.swing.GroupLayout.DEFAULT_SIZE, 372, Short.MAX_VALUE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addContainerGap()
                                .addComponent(jLabel2)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jRadioButtonMelhoresMesesDeVenda)
                        .addGap(38, 38, 38)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(botaoGerarGrafico, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(botaoGraficoPadrao, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(27, 27, 27)
                        .addComponent(painelGrafico, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(24, 24, 24)
                        .addComponent(botaoGerarGrafico))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel2)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(botaoGraficoPadrao)
                    .addComponent(jRadioButtonMelhoresLocaisDeVendas, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jRadioButtonMelhoresMesesDeVenda))
                .addGap(18, 18, 18)
                .addComponent(painelGrafico, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
    * @param args the command line arguments
    */

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton botaoGerarGrafico;
    private javax.swing.JButton botaoGraficoPadrao;
    private javax.swing.ButtonGroup grupoSelecaoDeGrafico;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JRadioButton jRadioButtonMelhoresLocaisDeVendas;
    private javax.swing.JRadioButton jRadioButtonMelhoresMesesDeVenda;
    private javax.swing.JPanel painelGrafico;
    // End of variables declaration//GEN-END:variables

    public ButtonGroup getGrupoSelecaoDeGrafico() {
        return grupoSelecaoDeGrafico;
    }

    public String getBotaoSelecionado() {
        if (jRadioButtonMelhoresLocaisDeVendas.isSelected())
        {
            return jRadioButtonMelhoresLocaisDeVendas.getText();
        }else if(jRadioButtonMelhoresMesesDeVenda.isSelected())

        {
            return jRadioButtonMelhoresMesesDeVenda.getText();
        }else
        {
            return "Selecione uma opção de pesquisa";
        }

    }

    public String getjRadioButtonMelhoresLocaisDeVendas() {
        return jRadioButtonMelhoresLocaisDeVendas.getText();
    }

    public String getjRadioButtonMelhoresMesesDeVenda() {
        return jRadioButtonMelhoresMesesDeVenda.getText();
    }

    public JPanel getPainelGrafico() {
        return painelGrafico;
    }

    public void setPainelGrafico(JPanel painelGrafico) {
        this.painelGrafico = painelGrafico;
    }

    public void setjLabel1(BufferedImage grafico) {
        this.jLabel1.setIcon(new ImageIcon(grafico));
    }



}
